Skip to content

feat: add shallow comparison option to ignore nested objects and arrays#48

Open
RafaelHubGit wants to merge 1 commit intoAsyncBanana:masterfrom
RafaelHubGit:shallow
Open

feat: add shallow comparison option to ignore nested objects and arrays#48
RafaelHubGit wants to merge 1 commit intoAsyncBanana:masterfrom
RafaelHubGit:shallow

Conversation

@RafaelHubGit
Copy link

Add new 'shallow' option to diff function that performs shallow comparison by only comparing primitive values at the first level and ignoring nested objects and arrays. This is useful when you only need to track changes in top-level primitive properties without recursing into complex structures.

Changes:

  • Add 'shallow' boolean option to Options interface
  • Skip objects/arrays in REMOVE, CHANGE, and CREATE operations when shallow mode is enabled
  • Update test data with simplified car examples instead of provider data
  • Add comprehensive tests for shallow vs deep comparison modes

Add new 'shallow' option to diff function that performs shallow comparison
by only comparing primitive values at the first level and ignoring nested
objects and arrays. This is useful when you only need to track changes in
top-level primitive properties without recursing into complex structures.

Changes:
- Add 'shallow' boolean option to Options interface
- Skip objects/arrays in REMOVE, CHANGE, and CREATE operations when shallow mode is enabled
- Update test data with simplified car examples instead of provider data
- Add comprehensive tests for shallow vs deep comparison modes
@AsyncBanana
Copy link
Owner

I am not entirely comfortable with the correctness sacrifices that need to be made for this change. If there is a clear use case that requires a level of performance that can only be achieved with shallow comparison while still needing the comparison capabilities offered by microdiff (rather than just a loop), I will reconsider. For now, I am putting this on ice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants